<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\User;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model app\models\User */
/* @var $form yii\widgets\ActiveForm */
/* @var $uploadForm app\models\UploadForm */
?>

<div class="user-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($uploadForm,'file')->fileInput()?>
    <?php if(!$model->isNewRecord):?>
        <div class="form-group">
            <div class="thumbnail">
                <?=Html::img(app\models\UploadForm::SHOW_DIR.$model->img)?>
            </div>
        </div>
    <?php endif;?>

    <?= $form->field($model, 'sex')->dropDownList(User::dropdown('sex'),['prompt'=>'性别']) ?>

    <?php if($model->type != User::IS_ROBOT):?>

    <?= $form->field($model, 'tele')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'pwd')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model,'fid')->dropDownList(ArrayHelper::map(User::getUsers(),'userid','name'),['prompt'=>'上级会员'])?>
    <?php endif;?>
    <?= $form->field($model, 'province')->dropDownList([],['id'=>'province'])?>

    <?= $form->field($model, 'city')->dropDownList([],['id'=>'city']) ?>

    <?= $form->field($model, 'county')->dropDownList([],['id'=>'county']) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

<?php $this->beginBlock('js')?>
<?=Html::jsFile('@admin/js/area.js')?>
<script>
    _init_area();
    $("#province").val("<?=$model->province?>");
    change(1);
    $("#city").val("<?=$model->city?>");
    change(2);
    $("#county").val("<?=$model->county?>");
</script>
<?php $this->endBlock();?>
